package com.human.service.impl;

import com.human.entity.ResultVo;
import com.human.entity.Salary;
import com.human.dao.SalaryMapper;
import com.human.service.ISalaryService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 * 工资账套 服务实现类
 * </p>
 *
 * @author jzq
 * @since 2023-03-07
 */
@Service
public class SalaryServiceImpl extends ServiceImpl<SalaryMapper, Salary> implements ISalaryService {

    @Resource
    SalaryMapper salaryMapper;

    @Override
    public ResultVo getSalaryById(Integer id) {
        Salary salary = salaryMapper.selectById(id);
        return new ResultVo(true, "查询成功", salary);
    }

    @Override
    public ResultVo getAllSalary() {
        List<Salary> salaryList = salaryMapper.selectList(null);
        return new ResultVo(true, "查询成功", salaryList);
    }

    @Override
    public ResultVo addSalary(Salary salary) {
        int i = salaryMapper.insert(salary);
        if (i > 0) {
            return new ResultVo(true, "添加成功", salary);
        }
        return new ResultVo(false, "添加失败");
    }

    @Override
    public ResultVo updateSalary(Salary salary) {
        int i = salaryMapper.updateById(salary);
        if (i > 0) {
            return new ResultVo(true, "修改成功", salary);
        }
        return new ResultVo(false, "修改失败");
    }

    @Override
    public ResultVo deleteSalaryById(Integer id) {
        int i = salaryMapper.deleteById(id);
        if (i > 0) {
            return new ResultVo(true, "删除成功");
        }
        return new ResultVo(false, "删除失败");
    }


}
